package com.boil.qz.safekavass.model;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Created by ChenYong on 2017-05-19.
 * <br>
 * 微信凭证实体类。
 */
@Entity
@Table(name = "TB_WEIXIN_ACCESS_TOKEN")
public class WeixinAccessToken implements Serializable {
    /**
     * 序列化
     */
    private static final long serialVersionUID = 8112206366833768334L;
    /**
     * 编号，主键
     */
    @Id
    @SequenceGenerator(name = "SqWeixinAccessToken", sequenceName = "SE_WEIXIN_ACCESS_TOKEN", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SqWeixinAccessToken")
    private Long id;
    /**
     * 凭证，唯一
     */
    private String accessToken;
    /**
     * 凭证有效时间，单位：秒
     */
    private Integer expiresIn;
    /**
     * 凭证到期代码：0-未到期；1-已到期
     */
    private Integer expiresCode;
    /**
     * 开始时间
     */
    private Date startTime;
    /**
     * 结束时间
     */
    private Date endTime;

    /**
     * 默认构造器。
     */
    public WeixinAccessToken() {
        super();
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Integer getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(Integer expiresIn) {
        this.expiresIn = expiresIn;
    }

    public Integer getExpiresCode() {
        return expiresCode;
    }

    public void setExpiresCode(Integer expiresCode) {
        this.expiresCode = expiresCode;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        WeixinAccessToken that = (WeixinAccessToken) o;

        return id != null ? id.equals(that.id) : that.id == null;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("WeixinAccessToken{");
        sb.append("id=").append(id);
        sb.append(", accessToken='").append(accessToken).append('\'');
        sb.append(", expiresIn=").append(expiresIn);
        sb.append(", expiresCode=").append(expiresCode);
        sb.append(", startTime=").append(startTime);
        sb.append(", endTime=").append(endTime);
        sb.append('}');
        return sb.toString();
    }
}